package com.bcu.calculus.service.serviceImpl;


import com.bcu.calculus.entity.*;
import com.bcu.calculus.mapper.IconMapper;
import com.bcu.calculus.service.IconService;
import com.bcu.calculus.utils.SendUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class IconServiceImpl implements IconService {

    @Resource
    private IconMapper iconMapper;

    @Override
    public Message<?> insertSelective(Icon icon) {
        String iconId = "IC" + SendUtil.genSendId();
        icon.setIconId(iconId);
        return iconMapper.insertSelective(icon)> 0 ? Message.success(null) : Message.fail(null);
    }

    @Override
    public Message<?> deleteByPrimaryKey(String iconId) {
        return iconMapper.deleteByPrimaryKey(iconId)> 0 ? Message.success(null) : Message.fail(null);
    }

    @Override
    public Message<?> updateByPrimaryKeySelective(Icon icon) {
        return iconMapper.updateByPrimaryKeySelective(icon)> 0 ? Message.success(null) : Message.fail(null);
    }

    @Override
    public Message<List<Icon>> selectAll() {
        return Message.success(null).add(iconMapper.selectAll());
    }

    @Override
    public Message<List<Icon>> selectById(String iconId) {
        return Message.success(null).add(iconMapper.selectById(iconId));
    }
}
